ManagerPanel = function(){
	var this_panel = this;

	this.listeners = {
			show : function(){
				this_panel.store.reload();
			}
	}
	
	var remove = function(){
		Ext.MessageBox.confirm("确认","确认删除管理员账号?",function(btn){
			if(btn == "yes"){
				var recs = this_panel.selModel.getSelections();
				var array = new Array();
				Ext.each(recs,function(rec,i){
					array.push(rec.get("id"));
				});
				var ids = array.join(",");
				Ajax({
					url : "manager/delete.action",
					params : {ids : ids},
					maskTarget : this_panel,
					grid : this_panel
				});
			}
		});
	};
	
	var sm = new Ext.grid.CheckboxSelectionModel({
		listeners : {
			selectionchange : function(){
				var num = this_panel.getSelectionModel().getSelections().length;
				this_panel.deleteButton.setDisabled(num==0);
//				this_panel.editButton.setDisabled(num!=1);
			}
		}
	});
	ManagerPanel.superclass.constructor.call(this, {
		title : "管理员配置",
		sm : sm,
		loadMask : true,
		tbar : [{
			text : "添加管理员",
			ref : "../addButton",
			iconCls : "user_add",
			handler : function(){
				addManagerWindow.show();
			}
		},{
			text : "删除管理员",
			ref : "../deleteButton",
			disabled : true,
			iconCls : "user_delete",
			handler : remove
		}
//		,{
//			text : "修改管理员",
//			ref : "../editButton",
//			disabled : true,
//			iconCls : "edit",
//			handler : function(){
//				var rec = this_panel.getSelectionModel().getSelected();
//				updatePurviewWindow.setData(object2Entity(rec.json, "manager"));
//				updatePurviewWindow.show();
//			}
//		}
		],
		columns : [sm,
		   		{
					hidden : true,
					dataIndex : "id"
		   		},{
		   			header : "管理员帐号名",
		   			dataIndex : "name"
		   		}
//		   		, {
//		   			header : "员工姓名",
//		   			dataIndex : "person"
//		   		}
		   		, {
		   			header : "权限",
		   			dataIndex : "purview",
		   			renderer : function(val){
		   				return val==2?"超级管理员":"管理员";
		   			}
		   		}],
		   		viewConfig: {
		   		        forceFit: true
		   		},
				store : new Ext.data.JsonStore({
					url : "manager/findAll.action",
					fields : [ "id","name","purview"]
				})
	});
};
Ext.extend(ManagerPanel, Ext.grid.GridPanel);
var managerPanel = new ManagerPanel();